﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LeEdu.Entity;
using LeEdu.Service;

namespace LeEdu.UI.Controllers
{
    /// <summary>
    /// 题目管理
    /// </summary>
    public class QuestionController : Controller
    {
		/// <summary>
		/// 实例化对象
		/// </summary>
		QuestionsService qservice = new QuestionsService();
		/// <summary>
		/// 题目显示
		/// </summary>
		/// <param name="id"></param>
		/// <param name="QType"></param>
		/// <param name="pageIndex"></param>
		/// <param name="pageSize"></param>
		/// <returns></returns>
		public ActionResult Index( string QType, int pageIndex = 1, int pageSize = 6)
        {
			try {
				int id = 1;
				int Cid = id;
				Session["Coursesid"] = id;  //绑定课程编号
				if (Cid == 0) {
					return Content("<script>alert('您还没有课程，不能管理题目，请添加！'); location.href='/Course/HourManage/?id=" + Cid + "' </script>");
				}
				//题目总数
				ViewBag.Count = qservice.GetQuestionCount();
				//当前页面
				ViewBag.pageIndex = pageIndex;
				//当前页面显示的条数
				ViewBag.pageSize = pageSize;
				//题目列表
				ViewBag.SelectList = qservice.GetAllQuestion(id);

				return View("Index");
			}
			catch (Exception) {
				return View();
			}
        }
	}
}